/*=====================================================================
  This file is part of a Microsoft SQL Server Shared Source Application.
  Copyright (C) Microsoft Corporation.  All rights reserved.
 
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
======================================================= */

using System;
using System.Collections.Generic;
using System.Text;

namespace RssStyleSheet
{
    public class Style
    {
        private const int GAIN_PERCENTAGE= 10;
        private const int LOSS_PERCENTAGE = 10;
        //Chart Title
        public static string Chart_TitleColor
        {
            get
            {
                return "#666666";
            }
        }

        public static string Chart_TitleSize
        {
            get
            {
                return "12pt";
            }
        }

        public static string Chart_TitleFont
        {
            get
            {
                return "Tahoma";
            }
        }

        public static string Chart_TitleThickness
        {
            get
            {
                return "Bold";
            }
        }

        //XYAxis
        public static string Chart_XYAxisSize
        {
            get
            {
                return "8pt";
            }
        }

        public static string Chart_XYAxisFont
        {
            get
            {
                return "Tahoma";
            }
        }

        public static string Chart_XYAxisThickness
        {
            get
            {
                return "normal";
            }
        }

        //xy axis title
        public static string Chart_XYAxisTitleSize
        {
            get
            {
                return "8pt";
            }
        }

        public static string Chart_XYAxisTitleFont
        {
            get
            {
                return "Tahoma";
            }
        }

        public static string Chart_XYAxisTitleThickness
        {
            get
            {
                return "Bold";
            }
        }

        //Legend
        public static string Chart_LegendSize
        {
            get
            {
                return "8pt";
            }
        }

        public static string Chart_LegendFont
        {
            get
            {
         
                return "Tahoma";
            }
        }

        public static string Chart_LegendThickness
        {
            get
            {
                return "Normal";
            }
        }




        public static string Chart_TopGradient
        {
            get
            {
                return "#FFFFFF";
            }
        }

        public static string Chart_BottomGradient
        {
            get
            {
                return "#E8EEF7";
            }
        }

        public static string Chart_PlotAreaGridLines
        {
            get
            {
                return "#CBDAEC";
            }
        }

        public static string Chart_Border
        {
            get
            {
                return "#000000";
            }
        }

        public static string Chart_Labels
        {
            get
            {
                return "#000000";
            }
        }


        ///Table Info

        public static string Table_Font
        {
            get
            {
                return "Tahoma";
            }
        }

        public static string Table_HeaderSize
        {
            get
            {
                return "10pt";
            }
        }

        public static string Table_HeaderFontColor
        {
            get
            {
                return "Black";
            }
        }

        public static string Table_TitleFontColor
        {
            get
            {
                return "Black";
            }
        }

        public static string Table_TitleSize
        {
            get
            {
                return "10pt";
            }
        }

        public static string Table_TitleThickness
        {
            get
            {
                return "Bold";
            }
        }

        public static string Table_HeaderBackground
        {
            get
            {
                return "#F1EFE2";
            }
        }

        public static string Table_HeaderThickness
        {
            get
            {
                return "Normal";
            }
        }

        public static string Table_RowSize
        {
            get
            {
                return "8pt";
            }
        }

        public static string Table_RowThickness
        {
            get
            {
                return "Normal";
            }
        }

        public static string Table_HyperLinkColor
        {
            get
            {
                return "#215DC6";
            }
        }
        
        public static string Table_HyperLinkTextDecoration
        {
            get
            {
                return "Underline";
            }
        }

        public static string Table_BorderStyle
        {
            get
            {
                return "Solid";
            }
        }

        public static string Table_BorderColor
        {
            get
            {
                return "#f1efe2";
            }
        }

        public static string GetPercentChangeColor(String Run1, String Run2, bool PositveIndicatesGain)
        {
            return GetPercentChangeColor(Run1, Run2, PositveIndicatesGain, GAIN_PERCENTAGE, LOSS_PERCENTAGE);
        }

        public static string GetPercentChangeColor(String Run1, String Run2, bool PositveIndicatesGain, int GainPercent,int LossPercent)
        {
            if (Run1 == null || Run2 == null)
            {
                return "Black";
            }

            float val1 = float.Parse(Run1);
            float val2 = float.Parse(Run2);

            if (val1 == 0)
            {
                return "Black";
            }

            float avg = ((val2 - val1) / val1) * 100;

            if (PositveIndicatesGain)
            {
                if ((avg > GainPercent))
                {
                    return "Green";
                }
                else if (avg < (LossPercent * -1))
                {
                    return "Red";
                }
            }
            else
            {
                if (avg < (GainPercent * -1))
                {
                    return "Green";
                }
                else if (avg > LossPercent)
                {
                    return "Red";
                }
            }

            return "Black";


        }

        //=RssStyleSheet.Style.GetPercentChangeColorForCounter(Fields!CumulativeValue1.Value,Fields!CumulativeValue2.Value,Fields!CounterName1.Value)

        public static string GetPercentChangeColorForCounter(String Run1, String Run2, String CounterName)
        {
            bool PositveIndicatesGain = false;
            if (CounterName.ToLower().Equals("% processor time"))
            {
                PositveIndicatesGain = false;
            }
            else if (CounterName.ToLower().Equals("available mbytes"))
            {
                PositveIndicatesGain = true;
            }
            else if (CounterName.ToLower().Equals("context switches/sec"))
            {
                PositveIndicatesGain = false;
            }
            return GetPercentChangeColor(Run1, Run2, PositveIndicatesGain) ;
        }
    }
}
